using System;

using JetBrains.Annotations;
using ProjectSurvivor;
using QFramework;
using UnityEngine;

public class UIGamePlanelItem
{
    public UIGamePlanelItem(bool isWepon)
    {
        Isweapon = isWepon;
    }
    public bool Isweapon = false;
    public bool UpradeFinish { get; set; } = false;
    public EasyEvent OnChanged = new EasyEvent();//EasyEvent 用于无参事件（如系统变动事件）。
    public bool UpgradeFinish { get; set; } = false;
    public string Key { get; private set; }
    public string Description { get;private set; }
    public int Price { get;set; }
    public int Lv { get;set; }
    public bool Visible { get;set; }
    public bool Name { get;set; }
    public void Upgrade()
    {
        mOnUpgrade?.Invoke(this);
        UpgradeFinish = true;
        OnChanged.Trigger();
        CoinUpgradeSystem.OnCoinUpgradeSystemChanged.Trigger();
        ExpUpgrdeSystem.OnExpUpgrdeSystemChanged.Trigger();
        Debug.Log(123457);
    }
    public bool CondtionCheck()
    {
        if (mOnUpgrade!=null)
        {
            return !UpgradeFinish&&mCondlite.Invoke(this);
        }
        return !UpgradeFinish;
    }
    public Action<UIGamePlanelItem> mOnUpgrade;
    public Func<UIGamePlanelItem, bool> mCondlite;
    public UIGamePlanelItem WithKey(string key)
    {
        Key = key;
        return this;
    }
    public UIGamePlanelItem WithName(string name)
    {
        Key = name;
        return this;
    }
    public UIGamePlanelItem WithDescription(string description)
    {
        Description = description;
        return this;
    }
    public UIGamePlanelItem WithDescription(Action<UIGamePlanelItem> onUpgrade)
    {
        mOnUpgrade = onUpgrade;
        return this;
    }
    public UIGamePlanelItem WithPrice(int price)
    {
        Price = price;
        return this;
    }

    public UIGamePlanelItem WithLv(int lv)
    {
        Lv = lv;
        return this;
    }
    public UIGamePlanelItem Condition(Func<UIGamePlanelItem,bool> Condlite)
    {
        mCondlite = Condlite;
        return this;
    }
}